using System;
using System.Threading.Tasks;
using SheLife.Domain.Entities;

namespace SheLife.Domain.Interfaces.Repositories
{
    /// <summary>
    /// 系统区域仓储接口
    /// </summary>
    public interface ISystemAreaRepository : IRepository<SystemArea>
    {
        /// <summary>
        /// 根据父级ID获取区域列表
        /// </summary>
        /// <param name="parentId">父级ID</param>
        /// <returns>区域列表</returns>
        Task<IEnumerable<SystemArea>> GetByParentIdAsync(Guid? parentId);

        /// <summary>
        /// 根据区域编码获取区域
        /// </summary>
        /// <param name="code">区域编码</param>
        /// <returns>区域</returns>
        Task<SystemArea> GetByCodeAsync(string code);

        /// <summary>
        /// 根据区域名称获取区域列表
        /// </summary>
        /// <param name="name">区域名称</param>
        /// <returns>区域列表</returns>
        Task<IEnumerable<SystemArea>> GetByNameAsync(string name);

        /// <summary>
        /// 根据区域级别获取区域列表
        /// </summary>
        /// <param name="level">区域级别</param>
        /// <returns>区域列表</returns>
        Task<IEnumerable<SystemArea>> GetByLevelAsync(int level);

        /// <summary>
        /// 检查区域编码是否存在
        /// </summary>
        /// <param name="code">区域编码</param>
        /// <returns>是否存在</returns>
        Task<bool> CheckAreaCodeExistsAsync(string code);

        /// <summary>
        /// 获取区域树
        /// </summary>
        /// <returns>区域树</returns>
        Task<IEnumerable<SystemArea>> GetAreaTreeAsync();

        /// <summary>
        /// 获取区域路径
        /// </summary>
        /// <param name="areaId">区域ID</param>
        /// <returns>区域路径</returns>
        Task<IEnumerable<SystemArea>> GetAreaPathAsync(Guid areaId);

        /// <summary>
        /// 获取区域列表（分页）
        /// </summary>
        /// <param name="pageIndex">页索引</param>
        /// <param name="pageSize">页大小</param>
        /// <param name="parentId">父级ID</param>
        /// <param name="level">区域级别</param>
        /// <param name="keyword">关键词</param>
        /// <returns>区域列表</returns>
        Task<(IEnumerable<SystemArea> Items, int TotalCount)> GetAreasPagedAsync(int pageIndex, int pageSize, Guid? parentId = null, int? level = null, string keyword = null);

        /// <summary>
        /// 启用区域
        /// </summary>
        /// <param name="areaId">区域ID</param>
        /// <param name="operatorId">操作人ID</param>
        /// <returns>是否成功</returns>
        Task<bool> EnableAreaAsync(Guid areaId, Guid operatorId);

        /// <summary>
        /// 禁用区域
        /// </summary>
        /// <param name="areaId">区域ID</param>
        /// <param name="operatorId">操作人ID</param>
        /// <returns>是否成功</returns>
        Task<bool> DisableAreaAsync(Guid areaId, Guid operatorId);

        /// <summary>
        /// 移动区域
        /// </summary>
        /// <param name="areaId">区域ID</param>
        /// <param name="newParentId">新父级ID</param>
        /// <param name="operatorId">操作人ID</param>
        /// <returns>是否成功</returns>
        Task<bool> MoveAreaAsync(Guid areaId, Guid? newParentId, Guid operatorId);

        /// <summary>
        /// 刷新区域缓存
        /// </summary>
        /// <returns>是否成功</returns>
        Task<bool> RefreshAreaCacheAsync();
    }
}